import requests
from common.get_header_tools import get_header
class IhrmEmpApi(object):
    def add_emp(self,req_header,req_body):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers=req_header,json=req_body)
        return resp
    def query_emp(self,emp_id,req_header):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/"+emp_id,
                            headers=req_header)
        return resp
    def modify_emp(self,emp_id,req_header,req_body):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/"+emp_id,
                            headers=req_header,json=req_body)
        return resp
    def delect_emp(self,emp_id,req_header):
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/"+emp_id,
                               headers=req_header)
        return resp
if __name__ == '__main__':
    ihrm = IhrmEmpApi()
    req_header = get_header()
    req_body ={
        "username": "user87655430",
        "mobile": "18842478283",
        "workNumber": "9527890aa"}
    resp = ihrm.add_emp(req_header,req_body)
    print("添加员工：",resp.json())
    id = "1609848950930550784"
    resp = ihrm.query_emp(id,req_header)